Fix tests for mac
authorAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 3 Apr 2018 15:23:02 +0000 (18:23 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 3 Apr 2018 18:02:43 +0000 (21:02 +0300)
src/cargo/ops/cargo_rustc/mod.rs
tests/testsuite/out_dir.rs

index 52e6cccaf28753fd196aa7e38e60d101d84aea43..5f75694824325a40b300a82497b8c0819fd7c3eb 100644 (file)
@@ -645,8 +645,12 @@ fn hardlink_or_copy(src: &Path, dst: &Path) -> CargoResult<()> {
         use std::os::windows::fs::symlink_dir as symlink;
 
         let dst_dir = dst.parent().unwrap();
-        assert!(src.starts_with(dst_dir));
-        symlink(src.strip_prefix(dst_dir).unwrap(), dst)
+        let src = if src.starts_with(dst_dir) {
+            src.strip_prefix(dst_dir).unwrap()
+        } else {
+            src
+        };
+        symlink(src, dst)
     } else {
         fs::hard_link(src, dst)
     };
index 9a241ae264c099496c188ad367553fbeea0018b7..ecb80fe67e87900b99f5aa013fb35c13911f9ffc 100644 (file)
@@ -1,11 +1,10 @@
 use std::path::Path;
 use std::fs::{self, File};
 use std::env;
-use std::io::Write;
 
 use hamcrest::assert_that;
 
-use cargotest::{process, ChannelChanger};
+use cargotest::{process, sleep_ms, ChannelChanger};
 use cargotest::support::{execs, project};
 
 #[test]
@@ -31,7 +30,7 @@ fn binary_with_debug() {
     check_dir_contents(
         &p.root().join("out"),
         &["foo"],
-        &["foo"],
+        &["foo", "foo.dSYM"],
         &["foo.exe", "foo.pdb"],
     );
 }
@@ -105,7 +104,7 @@ fn dynamic_library_with_debug() {
     check_dir_contents(
         &p.root().join("out"),
         &["libfoo.so"],
-        &["libfoo.so"],
+        &["libfoo.dylib"],
         &["foo.dll", "foo.dll.lib"],
     );
 }
@@ -194,7 +193,7 @@ fn include_only_the_binary_from_the_current_package() {
     check_dir_contents(
         &p.root().join("out"),
         &["foo"],
-        &["foo"],
+        &["foo", "foo.dSYM"],
         &["foo.exe", "foo.pdb"],
     );
 }
@@ -250,10 +249,8 @@ fn replaces_artifacts() {
         execs().with_stdout("foo"),
     );
 
-    fs::File::create(p.root().join("src/main.rs"))
-        .unwrap()
-        .write_all(br#"fn main() { println!("bar") }"#)
-        .unwrap();
+    sleep_ms(1000);
+    p.change_file("src/main.rs", r#"fn main() { println!("bar") }"#);
 
     assert_that(
         p.cargo("build -Z out-dir --out-dir out")